import { Component, OnInit } from '@angular/core';

interface ParentItemData {
  id: number,
          apply_name:string,
          state:string,
          function:string,
          endtime:string,
          expand:boolean
}

interface ChildrenItemData {
  name: string,
      state: string,
      start_command: string,
      explain: string,
      times: string,
      success_rate: string,
      QPS: string,
      delay: string,
      CPU: string,
      Memory: string,
      NPUGPU: string,
      disk: string,
}

@Component({
  selector: 'app-abilitybasic',
  templateUrl: './abilitybasic.component.html',
  styleUrls: ['./abilitybasic.component.css']
})
export class AbilitybasicComponent implements OnInit {
  //运行时配置表格数据
  runtimeConfigDate=[
    {
      paramName:"threshold",
      type:"int",
      limit:"int",
      configObject:"全局",
      param:""
    },
    {
      paramName:"min",
      type:"float",
      limit:"float",
      configObject:"全局",
      param:""
    },
    {
      paramName:"max",
      type:"float",
      limit:"float",
      configObject:"全局",
      param:""
    },
    {
      paramName:"num",
      type:"int",
      limit:"int",
      configObject:"视频",
      param:""
    },
  ];
  //更新模态框表格数据
  public updateModalData:any =[
    {
      aiAppName:"出行发票识别",
      currentVersion:"1.0.0",
      updatedVersion:"1.1.0"
    }
  ];
  //应用详情父级表格
  listOfParentData: ParentItemData[] = [];
  //应用详情内含表格
  listOfChildrenData: ChildrenItemData[] = [];
  state:number =1;
  //固件升级弹出框
  device_configIsVisable=false;
  //日志下载弹出框
  logDownloadIsVisable=false;
  //编辑弹出框
  editIsVisable=false;
  //运行时配置弹出框
  runtimeConfigIsVisable=false;
  //更新弹出框
  updateIsVisable=false;
  //编辑弹出框 实例名
  exampleName="";
  //编辑弹出框 启动指令
  startCommand="";
  //设备ip输入框
  ipInput1=192;
  ipInput2=168;
  ipInput3=137;
  ipInput4=7;
  //端口输入框
  portInput=8080;
  //运行时配置输入值
  runConfigInput="";
  //单选框选值
  radioValue="A";
  //更新第一页
  updateStepOne=true;
  //更新第二页
  updateStepTwo=false;


 

 
  constructor() { }
//测试
  qieHuan1():void {
     this.state=1;
     console.log("1");
  }
  qieHuan2():void {
    this.state=2;
    console.log("2");
 }
 //固件升级确定
 device_configOk():void{
   this.device_configIsVisable=false;
 }
 //固件升级取消
 device_configCancel():void{
  this.device_configIsVisable=false;
}
//点击设备配置
showdevice_configModal():void{
  this.device_configIsVisable=true;
}
//日志下载确定
logOk():void{
  this.logDownloadIsVisable=false;
}
//日志下载取消
logCancel():void{
  this.logDownloadIsVisable=false;
}
//编辑确定
editOk():void{
  this.editIsVisable=false;
}
//编辑取消
editCancel():void{
  this.editIsVisable=false;
}
//点击编辑
showEditModal():void{
  this.editIsVisable=true;
}
//点击share按钮
showLogDownloadModal():void{
  this.logDownloadIsVisable=true;
}
//运行时配置确定
runtimeConfigOk():void{
  this.runtimeConfigIsVisable=false;
}
//运行时配置取消
runtimeConfigCancel():void{
  this.runtimeConfigIsVisable=false;
}
//点击运行时配置
showruntimeConfigModal():void{
  this.runtimeConfigIsVisable=true;
}
//更新确认
updateOk():void{
  this.updateIsVisable=false;
}
//更新下一页
updateNext():void{
  this.updateStepOne=false;
  this.updateStepTwo=true;
}
//更新上一页
updateBack():void{
  this.updateStepOne=true;
  this.updateStepTwo=false;
}
//更新取消
updateCancel():void{
  this.updateIsVisable=false;
}
//更新模态框
showUpdateModal():void{
  this.updateIsVisable=true;
}
 //
checked = false;
indeterminate = false;
listOfCurrentPageData: ReadonlyArray<ParentItemData> = [];
listOfData: ReadonlyArray<ParentItemData> = [];
setOfCheckedId = new Set<number>();

updateCheckedSet(id: number, checked: boolean): void {
  if (checked) {
    this.setOfCheckedId.add(id);
  } else {
    this.setOfCheckedId.delete(id);
  }
}

onItemChecked(id: number, checked: boolean): void {
  this.updateCheckedSet(id, checked);
  this.refreshCheckedStatus();
}

onAllChecked(value: boolean): void {
  this.listOfCurrentPageData.forEach(item => this.updateCheckedSet(item.id, value));
  this.refreshCheckedStatus();
}

onCurrentPageDataChange($event: ReadonlyArray<ParentItemData>): void {
  this.listOfCurrentPageData = $event;
  this.refreshCheckedStatus();
}

refreshCheckedStatus(): void {
  this.checked = this.listOfCurrentPageData.every(item => this.setOfCheckedId.has(item.id));
  this.indeterminate = this.listOfCurrentPageData.some(item => this.setOfCheckedId.has(item.id)) && !this.checked;
}

ngOnInit(): void {
  this.listOfParentData = [
    {id: 1,
          apply_name:'发票识别',
          state:'可用',
          function:'出行发票识别',
          endtime:'2019/10/21 18:16:30',
          expand:false
        },
        {id: 2,
          apply_name:'证件识别',
          state:'可用',
          function:'身份证识别',
          endtime:'2019/10/21 18:16:30',
          expand:false
        },
        {id: 3,
          apply_name:'应用3',
          state:'可用',
          function:'功能',
          endtime:'2019/10/21 18:16:30',
          expand:false
        },
  ]

    this.listOfChildrenData=[
      {
      name: '出行发票识别',
      state: '可用',
      start_command: '-add-host=sssssssssssss',
      explain: '占位符',
      times: '1200',
      success_rate: '98%',
      QPS: '2',
      delay: '20ms',
      CPU: '50%',
      Memory: '50%',
      NPUGPU: '50%',
      disk: '50%',
    },
    {
      name: '出行发票识别',
      state: '可用',
      start_command: '-add-host=sssssssssssss',
      explain: '占位符',
      times: '1200',
      success_rate: '98%',
      QPS: '2',
      delay: '20ms',
      CPU: '50%',
      Memory: '50%',
      NPUGPU: '50%',
      disk: '50%',
    },
    {
      name: '出行发票识别',
      state: '可用',
      start_command: '-add-host=sssssssssssss',
      explain: '占位符',
      times: '1200',
      success_rate: '98%',
      QPS: '2',
      delay: '20ms',
      CPU: '50%',
      Memory: '50%',
      NPUGPU: '50%',
      disk: '50%',
    },
    {
      name: '出行发票识别',
      state: '可用',
      start_command: '-add-host=sssssssssssss',
      explain: '占位符',
      times: '1200',
      success_rate: '98%',
      QPS: '2',
      delay: '20ms',
      CPU: '50%',
      Memory: '50%',
      NPUGPU: '50%',
      disk: '50%',
    },

  ];

}
}
